package com.sky.mapper;

import com.sky.aop.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     *
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);


    Integer insertDish(Dish dish);

    List<DishVO> selectByPage(DishPageQueryDTO dishPageQueryDTO);


    Integer deleteByIds(List<Long> ids);

    List<Dish> list(Dish dish);

    @Select("select a.* from dish a left join setmeal_dish b on a.id = b.dish_id where b.setmeal_id = #{id}")
    List<Dish> selectSetmeal(Long id);

    /**
     * 查询菜品
     * @param id
     * @return
     */
    @Select("select * from dish where id = #{id}")
    Dish findById(Long id);

    @AutoFill(OperationType.UPDATE)
    Integer updataDish(Dish dish);




}
